import { createSlice, type PayloadAction } from "@reduxjs/toolkit";
import { type Subscription } from "react-native-ble-plx";
export const appSlice = createSlice({
  name: "App",
  initialState: {
    connectedDevice: null as null | string,
    currentRoute: null as null | string,
    SupConnectedDevice: null as null | Subscription,
  },
  reducers: {
    setConnectedDevice: (state, action: PayloadAction<string | null>) => {
      state.connectedDevice = action.payload;
    },
    setCurrentRoute: (state, action: PayloadAction<string | null>) => {
      state.currentRoute = action.payload;
    },
    setSupconnectedDevice: (
      state,
      action: PayloadAction<Subscription | null>
    ) => {
      state.SupConnectedDevice = action.payload;
    },
  },
});
export const { setConnectedDevice, setCurrentRoute,setSupconnectedDevice } = appSlice.actions;
export default appSlice.reducer;
